package com.example.readwrite;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;

public class ReadWriteLockDemo2 {

	public static void main(String[] args) {
		ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
		Lock readLock = readWriteLock.readLock();
		Lock writeLock = readWriteLock.writeLock();

		writeLock.lock();
		readLock.lock();
		System.out.println("写锁可以降级成读锁，但读锁不能升级为写锁");
		
		writeLock.unlock();
		readLock.unlock();
	}
}
